package com.ys.erp.entity.data.bean;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.Calendar;

/**
 * @author lwj
 * @date 2025/5/22
 */
    
@Data
@TableName(value = "t_user_pulse")
public class UserPulse {
    /**
     * 主键
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 编号
     */
    @TableField(value = "pulse_no")
    private String pulseNo;

    /**
     * 用户id
     */
    @TableField(value = "user_id")
    private Long userId;

    /**
     * 金额
     */
    @TableField(value = "pulse_num")
    private Long pulseNum;

    /**
     * 版本
     */
    @TableField(value = "version")
    @Version
    private Integer version;

    /**
     * 创建时间
     */
    @TableField(value = "create_time")
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @TableField(value = "update_time", update = "now()")
    private LocalDateTime updateTime;

    public String getRandOrderNo() {
        Calendar calendar = Calendar.getInstance();
        int month = calendar.get(Calendar.MONTH) + 1;
        int day = calendar.get(Calendar.DATE);
        return  "up"
                + calendar.get(Calendar.YEAR)
                + (month >= 10 ? String.valueOf(month) : "0" + month)
                + (day >= 10 ? String.valueOf(day) : "0" + day)
                + calendar.get(Calendar.HOUR_OF_DAY)
                + calendar.get(Calendar.MINUTE)
                + calendar.get(Calendar.SECOND)
                + ((int)((Math.random()*9+1)*10000000));
    }

}